package be.one.paq.ui;

import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Layout;
import com.vaadin.ui.VerticalLayout;

public abstract class PAQFixedAppLevelWindow extends FixedAppLevelWindow {
    
    protected Component header;   // Fixed width (see ancestor.pageWidth), inside headerBand. 
    protected Layout headerBand;  // Directly contains header. Goes from the left edge of the browser to the right edge.
    
    protected Component menu;   // Fixed width (see ancestor.pageWidth), inside menuBand. 
    protected Layout menuBand;  // Directly contains menu. Goes from the left edge of the browser to the right edge.

    protected Component footer;   // Fixed width (see ancestor.pageWidth), inside footerBand. 
    protected Layout footerBand;  // Directly contains footer. Goes from the left edge of the browser to the right edge.

    @Override
    protected ComponentContainer createComponents() {
        VerticalLayout windowContentLayout = (VerticalLayout)this.getContent();
        
        // Header
        header = createHeader();
        headerBand = createBandLayout( header );
        windowContentLayout.addComponent(headerBand);
        windowContentLayout.setComponentAlignment(headerBand, Alignment.TOP_CENTER);
        
        // Menu
        menu = createMenu();
        menuBand = createBandLayout( menu );
        windowContentLayout.addComponent(menuBand);
        windowContentLayout.setComponentAlignment(menuBand, Alignment.TOP_CENTER);

        // Center page area
        Layout pageBand = createBandLayout(null);
        windowContentLayout.addComponent(pageBand);
        windowContentLayout.setComponentAlignment(pageBand, Alignment.TOP_CENTER);
        windowContentLayout.setExpandRatio(pageBand, 1.0f);
        
        // Footer
        footer = createFooter();
        footerBand = createBandLayout( footer );
        windowContentLayout.addComponent(footerBand);
        windowContentLayout.setComponentAlignment(footerBand, Alignment.TOP_CENTER);

        return pageBand;
    }

    /** called by the template method createComponents. Override to provide your header component. */
    protected abstract Component createHeader();
    
    /** called by the template method createComponents. Override to provide your menu component. */
    protected abstract Component createMenu();

    /** called by the template method createComponents. Override to provide your footer component */
    protected abstract Component createFooter();

    
    public Component getHeader() {
        return header;
    }

    public Layout getHeaderBand() {
        return headerBand;
    }
    
    public Component getMenu() {
        return menu;
    }

    public Layout getMenuBand() {
        return menuBand;
    }

    public Component getFooter() {
        return footer;
    }

    public Layout getFooterBand() {
        return footerBand;
    }

}
